# @Version        : 1.0
# @Update Time    : 2025/10/26 23:13
# @File           : cli.py
# @IDE            : PyCharm
# @Desc           : 文件描述信息
import typer
from advanced_alchemy.cli import get_alchemy_group, add_migration_commands

app = typer.Typer()


@app.command()
def hello(name: str) -> None:
    """Says hello to the world."""
    typer.echo(f"Hello {name}")


@app.callback()
def callback():
    """
    Typer app, including Click subapp
    """
    pass


def create_cli() -> typer.Typer:
    """Create the CLI application with both Typer and Click commands."""
    # Get the Click group from advanced_alchemy
    alchemy_group = get_alchemy_group()

    # Convert our Typer app to a Click command object
    typer_click_object = typer.main.get_command(app)

    # Add all migration commands from the alchemy group to our CLI
    typer_click_object.add_command(add_migration_commands(alchemy_group))

    return typer_click_object


if __name__ == "__main__":
    cli = create_cli()
    cli()
